<template>
  <div class="detailBox" style="display: block">
    <div class="assets_H">
      <el-form :inline="true" :model="integral" class="demo-form-inline">
        <el-form-item label="用户查询：">
          <el-input
            v-model="integral.user"
            placeholder="请输入用户编号/昵称/手机号"
          ></el-input>
        </el-form-item>
        <el-form-item label="积分状态：">
          <el-select v-model="integral.status" placeholder="全部">
            <el-option
              v-for="item in options"
              :key="item.id"
              :label="item.value"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="积分发布期数：">
          <el-select v-model="integral.assetPeriods" placeholder="全部">
            <el-option
              v-for="item in options2"
              :key="item.id"
              :label="item.value"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="search">搜索</el-button>
          <el-button @click="reset">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="assets_B">
      <ex-table
        ref="table"
        :loading="loading"
        :table-column="tableColumn"
        :table-data="tableData"
        @pageSizeChange="handleSizeChange"
        @currentPageChange="handleCurrentChange"
      >
        <template v-slot:operate="{ scope }">
          <el-button @click="lookDetail(scope.row.id)">立即处理</el-button>
        </template>
      </ex-table>
    </div>
  </div>
</template>
<script>
import { adminUserInfo, adminAssetPeriods, adminDict } from "@/api/merchants";
import handlePageMixin from "@/mixins/handlePageMixin";
export default {
  name: "UserDetails",
  props: {},
  mixins: [handlePageMixin],
  data() {
    return {
      loading: false,
      date: [],
      integral: {
        user: "",
        status: "",
        assetPeriods: "",
      },
      assetId: "",
      options: [
        {
          id: "0",
          value: "全部",
        },
        // {
        //   value: "1",
        //   label: "正常",
        // },
        // {
        //   value: "2",
        //   label: "黑名单",
        // },
      ],
      options2: [
        {
          id: "0",
          value: "全部",
        },
      ],
      tableData: [],
      tableColumn: [
        { prop: "id", label: "用户编号" },
        { prop: "name", label: "会员昵称" },
        { prop: "phone", label: "会员手机号" },
        { prop: "usable", label: "剩余积分" },
        { prop: "used", label: "已使用积分" },
        { prop: "overdue", label: "过期积分" },
        { prop: "total", label: "累计获得积分" },
        { prop: "statusDict", label: "积分状态" },
        { prop: "currentAssetPeriods", label: "所处期数" },
        { prop: "userAddress", label: "账户地址" },
      ],
    };
  },
  mounted() {
    console.log(this.$route.query);
    let query = this.$route.query
    this.assetId = query.assetId
    this.getBalancedlist();
    this.getadminAssetPeriods();
    this.getList();
  },
  methods: {
    getBalancedlist() {
      //获取积分状态
      const params = {
        dictType: "consumer_wallet_status",
      };
      adminDict(params).then((res) => {
        var arr = [
          {
            id: "",
            value: "全部",
          },
        ];
        this.options = arr.concat(res.result[0].dictList);
      });
    },
    getadminAssetPeriods() {
      //积分发布期数
      const params = {
        assetId: this.assetId,
      };
      adminAssetPeriods(params).then((res) => {
        var arr = [
          {
            id: "",
            value: "全部",
          },
        ];
        this.options2 = arr.concat(res.result);
      });
    },
    search() {
      console.log(this.integral);
      this.pageOptions.pageNum = 1
      this.$refs.table.pageOptions.pageNum = 1
      this.getList();
    },
    reset() {
      this.integral = {};
      this.pageOptions.pageNum = 1
      this.$refs.table.pageOptions.pageNum = 1
      this.getList();
    },
    getList() {
      const params = {
        ...this.pageOptions,
        ...this.integral,
        assetId: this.assetId,
      };
      this.loading = true;
      adminUserInfo(params)
        .then((res) => {
          const { total, records } = res.result;
          this.tableData = records;
          this.$refs.table.pageOptions.total = total;
        })
        .finally(() => {
          this.loading = false;
        });
    },
  },
};
</script>
<style scoped>
.el-form--inline .el-form-item {
  margin-right: 20px;
}
</style>